import Vue from 'vue'
import Router from 'vue-router';


Vue.use(Router)

/**
 * 重写路由的push方法
 */
// const routerPush = Router.prototype.push
// Router.prototype.push = function push(location) {
//     return routerPush.call(this, location).catch(error => error)
// }

/* Layout */
import Layout from '@/views/layout/Layout'

const login = r => require.ensure([], () => r(require('@/views/login')), 'login');
const aTest = r => require.ensure([], () => r(require('@/views/antibody/aTest')), 'aTest');
const aHistory = r => require.ensure([], () => r(require('@/views/antibody/aHistory')), 'aHistory');
const aDetail = r => require.ensure([], () => r(require('@/views/antibody/aDetail')), 'aDetail');
const pTest = r => require.ensure([], () => r(require('@/views/pisa/pTest')), 'pTest');
const pHistory = r => require.ensure([], () => r(require('@/views/pisa/pHistory')), 'pHistory');
const pDetail = r => require.ensure([], () => r(require('@/views/pisa/pDetail')), 'pDetail');
const vTest = r => require.ensure([], () => r(require('@/views/virus/vTest')), 'vTest');
const vTest2 = r => require.ensure([], () => r(require('@/views/virus/vTest/vTest')), 'vTest2');
const vHistory = r => require.ensure([], () => r(require('@/views/virus/vHistory')), 'vHistory');
const vDetail = r => require.ensure([], () => r(require('@/views/virus/vDetail')), 'vDetail');
const newATest = r => require.ensure([], () => r(require('@/views/antibodyNew/newATest')), 'newATest');
const newAHistory = r => require.ensure([], () => r(require('@/views/antibodyNew/newAHistory')), 'newAHistory');
const newADetail = r => require.ensure([], () => r(require('@/views/antibodyNew/newADetail')), 'newADetail');

export const constantRouterMap = [{
  path: '/login',
  component: login,
  hidden: true
}, {
  path: '/',
  component: Layout,
  alwaysShow: true,
  meta: {
    title: 'page.virus',
    icon: 'virus'
  },
  children: [
    {
      path: '/virusCd2',
      component: vTest2,
      name: "virusCd2",
      hidden: true,
      meta: {
        title: '上传多文件',
      },
    },
    {
      path: '/',
      component: vTest,
      name: "virusCd",
      meta: {
        title: 'page.upload',
      },
    }, {
      path: '/vHistory',
      component: vHistory,
      name: "vHistory",
      meta: {
        title: 'page.history',

      },
    }, {
      path: '/vDetail',
      component: vDetail,
      name: "vDetail",
      hidden: true,
      meta: {
        title: 'page.detial',
      },
    }]
}, {
  path: '/newAbody',
  component: Layout,
  alwaysShow: true,
  meta: {
    title: 'page.newAbody',
    icon: 'antibody'
  },
  children: [{
    path: '/newATest',
    component: newATest,
    name: "newATest",
    meta: {
      title: 'page.upload',
    },
  }, {
    path: '/newAHistory',
    component: newAHistory,
    name: "newAHistory",
    meta: {
      title: 'page.history',
    },
  }, {
    path: '/newADetail',
    component: newADetail,
    name: "newADetail",
    hidden: true,
    meta: {
      title: 'page.detail',
    },
  }
  ]
}, {
  path: '/antibody',
  component: Layout,
  alwaysShow: true,
  meta: {
    title: "page.affinity",
    icon: 'tree'
  },
  children: [{
    path: '/antibodyCd',
    component: aTest,
    name: "antibodyCd",
    meta: {
      title: 'page.upload',
    },
  }, {
    path: '/aHistory',
    component: aHistory,
    name: "aHistory",
    meta: {
      title: 'page.history',
    },
  }, {
    path: '/aDetail',
    component: aDetail,
    name: "aDetail",
    hidden: true,
    meta: {
      title: 'page.detial',
    },
  }]
}, {
  path: '/pisa',
  component: Layout,
  name: 'pisa',
  alwaysShow: true,
  meta: {
    title: 'page.protein',
    icon: 'pisa'
  },
  children: [{
    path: '/pisaCd',
    component: pTest,
    name: "pisaCd",
    meta: {
      title: 'page.upload',
    },
  },
    // {
    //     path: '/pHistory',
    //     component: pHistory,
    //     name: "pHistory",
    //     meta: {
    //         title: '查看历史',
    //         keepAlive: true
    //     },
    // },
    // {
    // path: '/pDetail',
    // component: pDetail,
    // name: "pDetail",
    // hidden: true,
    // meta: {
    //     title: '历史详情',
    // },
    // }
  ]
}
]

/* 初始路由 */
export default new VueRouter({
  // mode: 'history', //后端支持可开
  scrollBehavior(to, from, savedPosition) {
    return {
      x: 0,
      y: 0
    }
  },
  routes: constantRouterMap
})

export const asyncRouterMap = []



export const allRoutes = []